package org.beans.expense.common;

import org.apache.wicket.protocol.http.WebApplication;
import org.beans.expense.common.page.DailyExpensesPage;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * Application object for your web application. If you want to run this application without deploying, run the Start class.
 *
 * @see wicket.myproject.Start#main(String[])
 */
public class WicketApplication extends WebApplication
{
    /**
     * Constructor
     */
    public WicketApplication()
    {
    }

    @Override
    protected void init()
    {
        super.init();

        //spring support in wicket classes
        //getComponentInstantiationListeners().add((IComponentInstantiationListener) new SpringComponentInjector(this, getSpringContext()));
    }

    public Class getHomePage()
    {
        return DailyExpensesPage.class;
    }

    public ApplicationContext getSpringContext()
    {
        // return this context;
        return WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    }
}
